<template>
	<view class="page" :style="{minHeight:$height()}">
		<view class="header">
			<view class="title">
				售电小程序
			</view>
			<view class="headerContent">
				<view class="headerPortrait">
					<!-- <image :src="userinfo.avatar" class="image" style="width: 100%;height: 100%;"></image> -->
					<image src="@/static/Icon/tou2.gif" class="image" style="width: 100%;height: 100%;"></image>
				</view>
				<view class="mate">
					<view class="mateTop">
						<view class="mateTitle" v-if="userinfo.realname" style="font-size: 32rpx;">
							{{userinfo.realname||""}}
						</view>

						<view class="fill-info" @click="$next(`/pages/mine/userSetting`)"
							v-if="userinfo.userType == 1 && showSign == true">
							点击完善基础信息
						</view>
						<view class="area" v-if="userinfo.district">
							{{userinfo.district.mergerName.split(',')[0]}}
						</view>
					</view>

					<view class="mateBom">
						<view class="tel">
							{{mobile}}
						</view>

					</view>
				</view>
			</view>
		</view>

		<view class="byder">
			<view class="accauant">
				<image src="@/static/image/qian.png" class="image" style="width: 20rpx;height: 20rpx;"></image>
				<view class="accauantTxt">
					我的账户
				</view>
				<u-icon name="eye"></u-icon>
			</view>
			<view class="itemBox">
				<view class="item" @click="$next(`/pages/commissionCenters/index`)">
					<view class="numbel">
						{{userinfo.money}}
					</view>
					<view class="itemTitle">账户余额（元）</view>
				</view>
				<view class="item" @click="$next(`/pages/commissionCenters/commissionIndex`)">
					<view class="numbel">
						{{commissionCount.totalMoney||'0.00'}}
					</view>
					<view class="itemTitle">佣金累计（元）</view>
				</view>
				<view class="item" @click="$next(`/pages/functionCore/customer/list`)">
					<view class="numbel">
						{{commissionCount.totalFlowCustom}}
					</view>
					<view class="itemTitle">拜访客户（家）</view>
				</view>

			</view>
		</view>
		<view class="list" @click="$next(`/pages/mine/myContractList`,true)">
			<view class="kuai">
				<image src="@/static/image/hetong.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				我的合同
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>

		<view class="list" @click="$next(`/pages/functionCore/customer/list`,true)">
			<view class="kuai" style="background-color: #4EC7FF;">
				<image src="@/static/image/kehu.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				我的客户
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		<view class="list" @click="navPerson">
			<view class="kuai" style="background-color: #68bf7b;">
				<image src="@/static/image/person.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				个人信息
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		<view class="list" @click="TownMayor" >
			<view class="kuai" style="background-color: #4EC7FF;">
				<image src="@/static/image/person.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				镇长申请
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		<view class="list" @click="TownMayorMange" v-if="permissions[0] == '镇长管理'">
			<view class="kuai" style="background-color: #4EC7FF;">
				<image src="@/static/image/person.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				镇长管理
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		
		<view class="list" @click="$next(`/pages/mine/promoted`)">
			<view class="kuai" style="background-color: #2E6ADF;">
				<image src="@/static/image/kehu.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				售电推广
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		
		<view class="list" @click="$next(`/pages/mine/floder?type=0`)">
			<view class="kuai" style="background-color: #1296db;">
				<image src="@/static/Icon/resource.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				签约资料包
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		<view class="list" @click="$next(`/pages/mine/floder?type=1`)">
			<view class="kuai" style="background-color: #d4237a;">
				<image src="@/static/Icon/resource.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				售电资料包
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>

		<!-- <view class="list" @click="heHuoRen" v-if="userinfo.userType != 2">
			<view class="kuai" style="background-color: #F35B47;">
				<image src="@/static/image/kehu.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				合伙人申请
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view> -->

		<!-- <view class="list">
			<view class="kuai" style="background-color: #F35B47;">
				<image src="@/static/image/dizhi.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				地址管理
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		<view class="list">
			<view class="kuai">
				<image src="@/static/image/qiandao.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				签到记录
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view>
		<view class="list">
			<view class="kuai" style="background-color: #4EC7FF;">
				<image src="@/static/image/baifang.png" class="image" style="width: 24rpx;height: 24rpx;"></image>
			</view>
			<view class="txt">
				拜访记录
			</view>
			<u-icon name="arrow-right" style="font-size: 36rpx; color: #707070;"></u-icon>
		</view> -->


		<view class="footer"></view>
		<status-modal :showSign="showSign" :showSignTownerContract="showSignTownerContract" :showSignContract="showSignContract" :showStatus="showStatus" 
			:tenantCode="tenantCode" :userType="userType" :updateDate="userinfo.updateDate"></status-modal>
	</view>
</template>

<script>
	import statusModal from '@/components/statusModal/statusModal.vue'
	import selectRegion from '@/mixin/selectRegion'
	export default {
		mixins: [selectRegion], // 使用混入
		data() {
			return {
				showSign: false,
				showSignContract: false,
				showSignTownerContract: false,
				showStatus: false,
				userType: 0,
				commissionCount: {},
				userinfo: {},
				mobile: "",
				tenantCode: uni.getStorageSync("tenantCode"),
				permissions:[]
			}
		},
		components: {
			statusModal
		},
		onLoad() {

		},

		onShow() {
			this.getUser()
			this.getCommissionCount()
			this.getTownMayor()
		},
		methods: {
			getCommissionCount() {
				this.$axios.request(this.$api.getCommissionCount, "GET").then((val) => {
					this.commissionCount = val.data
				})
			},
			navPerson() {
				uni.navigateTo({
					url: '/pages/mine/personInfo'
				})
			},
			
			// 跳转到申请电长页面
			TownMayor() {
				uni.navigateTo({
					url: `/pages/mine/TownMayor?provinceId=${this.userinfo.provinceId}`
				})
			},
			TownMayorMange() {
				uni.navigateTo({
					url: `/pages/mine/zhenZhangList`
				})
			},
			heHuoRen() {
				uni.navigateTo({
					url: `/pages/mine/heZuoHuoBanStting`
				})
			},
			// 获取电长权限
			getTownMayor() {
				this.$axios.request(this.$api.getTownMayorApi, "GET").then((val) => {
					this.permissions = val.data.permissions
					console.log(this.permissions,'this.permissions')
				})
			},
			getUser() {
				this.$axios.request(this.$api.getUser, "GET").then((val) => {
					this.userinfo = val.data
					this.userType = val.data.userType
					if (val.data.realname == '' ) {
						this.showSign = true
						this.showStatus = false
						this.showSignContract = false
						this.showSignTownerContract = false
					} else if (val.data.status == 0) {
						this.showStatus = true
						this.showSign = false
						this.showSignContract = false
						this.showSignTownerContract = false
					} else if (val.data.status == 1 && val.data.sign == 0) {
						this.showSignContract = true //签署合同弹框
						this.showSign = false //签署劳务合同,就是让用户去注册
						this.showStatus = false // 企业审核中
						this.showSignTownerContract = false // 企业审核中
					}else if (val.data.hasNoSignTowner == true) {
						console.log(val.data.hasNoSignTowner)
						this.showSign = false
						this.showStatus = false
						this.showSignContract = false
						this.showSignTownerContract = true
					} else {
						this.showSign = false
						this.showStatus = false
						this.showSignContract = false
						this.showSignTownerContract = false
					}
					this.mobile = val.data.mobile.substr(0, 3) + "****" + val.data.mobile.substr(7)
				})
			},


		}
	}
</script>

<style>
	.page {
		width: 100%;
		background-color: #F0F2F5;
	}

	.header {
		overflow: hidden;
		width: 100%;
		height: 360rpx;
		background-color: #2E6ADF;
		padding: 0 32rpx;
	}

	.title {
		height: 48rpx;
		font-size: 34rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		line-height: 48rpx;
		color: #FFFFFF;
		text-align: center;
		margin-top: 108rpx;
	}

	.headerContent {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		height: 120rpx;
		margin-top: 52rpx;
	}

	.headerPortrait {
		width: 120rpx;
		height: 120rpx;
		border-radius: 60rpx;
		overflow: hidden;
		background-color: #007AFF;
		background-color: #FFFFFF;
	}

	.mate {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		width: 530rpx;
		height: 90rpx;
	}

	.mateTop,
	.mateBom {
		width: 532rpx;
		height: 40rpx;
		display: flex;
		justify-content: flex-start;
		align-items: flex-end;
	}

	.setting {
		height: 40rpx;
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		line-height: 40rpx;
		padding: 0 10rpx;
		color: #FFFFFF;
		background-color: #01A0FB;
	}

	.fill-info {
		height: 40rpx;
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		line-height: 40rpx;
		padding: 0 10rpx;
		color: #FFFFFF;
		background-color: #FF9800;
	}

	.area {
		height: 40rpx;
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		line-height: 40rpx;
		margin-left: 20rpx;
		padding: 0 10rpx;
		color: #FFFFFF;
		background-color: #01A0FB;
	}

	.mateTitle {
		height: 48rpx;
		font-size: 32rpx;
		margin-right: 20rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		line-height: 64rpx;
		color: #FFFFFF;
		/* margin-right: 64rpx; */
	}

	.tel {
		font-size: 24rpx;
		color: #FFFFFF;
	}

	.edit {
		font-size: 20rpx;
		color: #FFFFFF;
		margin-left: 31rpx;
	}

	.accauant {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		width: 686rpx;
		margin: 16rpx auto 0;
		height: 64rpx;
		border-bottom: 1rpx solid #C0C0C0;
		background-color: #FFFFFF;
	}

	.accauantTxt {
		height: 33rpx;
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		line-height: 33rpx;
		margin: 0 10rpx;
		color: #333333;
	}

	.itemBox {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 610rpx;
		height: 150rpx;
		margin: 0 auto 0;
	}

	.item {
		height: 150rpx;
		display: flex;
		justify-content: flex-end;
		flex-direction: column;
		align-items: center;
	}

	.numbel {
		height: 50rpx;
		font-size: 36rpx;
		text-align: center;
		width: 100%;
		font-family: "PingFang SC";
		font-weight: 500;
		line-height: 35rpx;
		color: #7B7B7B;
		margin-bottom: 17rpx;
	}

	.itemTitle {
		width: 100%;
		text-align: center;
		height: 28rpx;
		font-size: 20rpx;
		font-family: "PingFang SC";
		font-weight: 500;
		line-height: 35rpx;
		color: #BBBBBB;
		margin-bottom: 17rpx;
	}

	.byder {
		width: 100%;
		height: 230rpx;
		overflow: hidden;
		background-color: #FFFFFF;
		margin-bottom: 16rpx;
	}

	.list {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 750rpx;
		height: 85rpx;
		background-color: #FFFFFF;
		margin-bottom: 4rpx;
		padding: 0 32rpx;
	}

	.txt {
		width: 570rpx;
		padding: 0 10rpx;
	}

	.kuai {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 48rpx;
		height: 48rpx;
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		line-height: 30rpx;
		color: #707070;
		background-color: #2E6ADF;
	}

	.footer {
		width: 100%;
		height: 100%;
		background-color: #FFFFFF;
	}
</style>
